package com.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vo.MailUser;

import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author 
 */
public class Member extends MailUser implements Serializable,Account {
    private String mno;

    @Size(message = "姓名太长",max = 5)
    private String mname;

    private String mpwd;

    private String msex;

    private Date mbirthday;

    private Date mjoinday;

    private String mdesc;

    private String mheadimg;

    private String memail;

    private String mphone;

    private Integer mcount;


//shiro 准备 登录用的 成员变量和方法
   @JsonIgnore
	String salt;//加密用的盐
	Integer isDelete;
	Date createDate;
	Boolean locked = Boolean.FALSE;//是否锁定

    List<AccountRole> accountRoles;

    @JsonIgnore
    @Override
    public String getAccountid() {
        return mno;
    }


    @JsonIgnore
    @Override
    public String getAccountname() {
        return mname;
    }

//@JsonIgnore json序列化时候 不处理这个字段 写在get方法也可
    @JsonIgnore
    @Override
    public String getPassword() {
        return mpwd;
    }



    @Override
    public String getSalt() {
        return salt;
    }


    public void setSalt(String salt) {
        this.salt = salt;
    }

    @Override
    public Integer getIsDelete() {
        return isDelete;
    }


    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    @Override
    public Date getCreateDate() {
        return createDate;
    }


    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Override
    public Boolean getLocked() {
        return locked;
    }


    public void setLocked(Boolean locked) {
        this.locked = locked;
    }

    @Override
    public List<AccountRole> getAccountRoles() {
        return accountRoles;
    }


    public void setAccountRoles(List<AccountRole> accountRoles) {
        this.accountRoles = accountRoles;
    }
    @JsonIgnore
    public String getCredentialsSalt()
    {
        return getAccountname() + salt;
    }
    //结束    shiro 准备 登录用的 成员变量和方法


    private List<Memberflolowexpert> memberflolowexperts;
    private List<Memberfollowteam> memberfollowteams;

    public List<Memberflolowexpert> getMemberflolowexperts() {
        return memberflolowexperts;
    }

    public void setMemberflolowexperts(List<Memberflolowexpert> memberflolowexperts) {
        this.memberflolowexperts = memberflolowexperts;
    }

    public List<Memberfollowteam> getMemberfollowteams() {
        return memberfollowteams;
    }

    public void setMemberfollowteams(List<Memberfollowteam> memberfollowteams) {
        this.memberfollowteams = memberfollowteams;
    }

    private static final long serialVersionUID = 1L;

    public String getMno() {
        return mno;
    }

    public void setMno(String mno) {
        this.mno = mno;
    }

    public String getMname() {
        return mname;
    }

    public void setMname(String mname) {
        this.mname = mname;
        this.mailName = mname;
    }

    public String getMpwd() {
        return mpwd;
    }

    public void setMpwd(String mpwd) {
        this.mpwd = mpwd;
    }






    public String getMsex() {
        return msex;
    }

    public void setMsex(String msex) {
        this.msex = msex;
    }

    public Date getMbirthday() {
        return mbirthday;
    }

    public void setMbirthday(Date mbirthday) {
        this.mbirthday = mbirthday;
    }

    public Date getMjoinday() {
        return mjoinday;
    }

    public void setMjoinday(Date mjoinday) {
        this.mjoinday = mjoinday;
    }

    public String getMdesc() {
        return mdesc;
    }

    public void setMdesc(String mdesc) {
        this.mdesc = mdesc;
    }

    public String getMheadimg() {
        return mheadimg;
    }

    public void setMheadimg(String mheadimg) {
        this.mheadimg = mheadimg;
    }

    public String getMemail() {
        return memail;
    }

    public void setMemail(String memail) {
        this.memail = memail;
        this.mailAddress = memail;
    }

    public String getMphone() {
        return mphone;
    }

    public void setMphone(String mphone) {
        this.mphone = mphone;
    }

    public Integer getMcount() {
        return mcount;
    }

    public void setMcount(Integer mcount) {
        this.mcount = mcount;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Member other = (Member) that;
        return (this.getMno() == null ? other.getMno() == null : this.getMno().equals(other.getMno()))
            && (this.getMname() == null ? other.getMname() == null : this.getMname().equals(other.getMname()))
            && (this.getMpwd() == null ? other.getMpwd() == null : this.getMpwd().equals(other.getMpwd()))
            && (this.getMsex() == null ? other.getMsex() == null : this.getMsex().equals(other.getMsex()))
            && (this.getMbirthday() == null ? other.getMbirthday() == null : this.getMbirthday().equals(other.getMbirthday()))
            && (this.getMjoinday() == null ? other.getMjoinday() == null : this.getMjoinday().equals(other.getMjoinday()))
            && (this.getMdesc() == null ? other.getMdesc() == null : this.getMdesc().equals(other.getMdesc()))
            && (this.getMheadimg() == null ? other.getMheadimg() == null : this.getMheadimg().equals(other.getMheadimg()))
            && (this.getMemail() == null ? other.getMemail() == null : this.getMemail().equals(other.getMemail()))
            && (this.getMphone() == null ? other.getMphone() == null : this.getMphone().equals(other.getMphone()))
            && (this.getMcount() == null ? other.getMcount() == null : this.getMcount().equals(other.getMcount()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getMno() == null) ? 0 : getMno().hashCode());
        result = prime * result + ((getMname() == null) ? 0 : getMname().hashCode());
        result = prime * result + ((getMpwd() == null) ? 0 : getMpwd().hashCode());
        result = prime * result + ((getMsex() == null) ? 0 : getMsex().hashCode());
        result = prime * result + ((getMbirthday() == null) ? 0 : getMbirthday().hashCode());
        result = prime * result + ((getMjoinday() == null) ? 0 : getMjoinday().hashCode());
        result = prime * result + ((getMdesc() == null) ? 0 : getMdesc().hashCode());
        result = prime * result + ((getMheadimg() == null) ? 0 : getMheadimg().hashCode());
        result = prime * result + ((getMemail() == null) ? 0 : getMemail().hashCode());
        result = prime * result + ((getMphone() == null) ? 0 : getMphone().hashCode());
        result = prime * result + ((getMcount() == null) ? 0 : getMcount().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", mno=").append(mno);
        sb.append(", mname=").append(mname);
        sb.append(", mpwd=").append(mpwd);
        sb.append(", msex=").append(msex);
        sb.append(", mbirthday=").append(mbirthday);
        sb.append(", mjoinday=").append(mjoinday);
        sb.append(", mdesc=").append(mdesc);
        sb.append(", mheadimg=").append(mheadimg);
        sb.append(", memail=").append(memail);
        sb.append(", mphone=").append(mphone);
        sb.append(", mcount=").append(mcount);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}